package com.lzb.party.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzb.party.entity.Notice;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface NoticeMapper extends BaseMapper<Notice> {

    @Select("Select * from notice")
    List<Notice> findAll();

    //时间戳为数据库自动添加,num为自动递增
    @Insert("INSERT into notice(name, message) values " +
            "(#{name}, #{message})")
    int insert(Notice notice);

    int update(Notice notice);

    @Delete("delete from notice where num = #{num}")
    Integer deleteById(@Param("num") String num);

    @Select("SELECT * FROM `notice` where name like #{name} && num like #{num} limit #{pageNum}, #{pageSize}")
    List<Notice> selectPage(Integer pageNum, Integer pageSize, String name, String num);

    @Select("select count(*) from notice where name like #{name} && num like #{num}")
    Integer selectTotal(String name, String num);
}
